#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int N = 100005;
struct node {
	int id, cnt;
}d[N];
bool cmp (node x, node y) {
	return x.id < y.id;
}
string str;
int t[7] = {1, 10, 100, 1000, 10000, 100000, 1000000};
int change (string s) {
	int a[7];
	int cnt = 6;
	int num;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '-') {
			continue;
		} else if (s[i] <= '9' && s[i] >= '0') {
			a[cnt] = s[i] - '0';
			cnt--;
		} else {
			if (s[i] == 'A' || s[i] == 'B' || s[i] == 'C') {
				a[cnt] = 2;
				cnt--;
			} else if (s[i] == 'D' || s[i] == 'E' || s[i] == 'F') {
				a[cnt] = 3;
				cnt--;
			} else if (s[i] == 'G' || s[i] == 'H' || s[i] == 'I') {
				a[cnt] = 4;
				cnt--;
			} else if (s[i] == 'J' || s[i] == 'K' || s[i] == 'L') {
				a[cnt] = 5;
				cnt--;
			} else if (s[i] == 'M' || s[i] == 'N' || s[i] == 'O') {
				a[cnt] = 6;
				cnt--;
			} else if (s[i] == 'P' || s[i] == 'R' || s[i] == 'S') {
				a[cnt] = 7;
				cnt--;
			} else if (s[i] == 'T' || s[i] == 'U' || s[i] == 'V') {
				a[cnt] = 8;
				cnt--;
			} else if (s[i] == 'W' || s[i] == 'X' || s[i] == 'Y') {
				a[cnt] = 9;
				cnt--;
			} else {
				continue;
			}
		}
	}
	for (int i = 0; i < 7; i++) {
		num += a[i] * t[i];
	}
	num--;
	return num;
}
void change1 (int x) {
	int a[7];
	for (int i = 6; i >= 0; i--) {
		a[i] = x % 10;
		x /= 10;
	}
	for (int i = 0; i < 3; i++) {
		str += (char)(a[i]);	
	}
	str += "-";
	for (int i = 3; i < 7; i++) {
		str += (char)(a[i]);	
	}
}
int main() {
	std::ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s;
		int x = change(s);
		bool tmp = 0;
		for (int j = 1; j < i; j++) {
			if (d[j].id == x) {
				d[j].cnt++;
				tmp = 1;
			}
		}
		if (!tmp) {
			d[i].id = x;
			d[i].cnt = 1;
		}
	}
	bool tmp = 0;
	for (int i = 1; i <= n; i++) {
		if (d[i].cnt > 1) {
			tmp = 1;
		}
	}
	if (!tmp) {
		cout << "No duplicates." << endl;
	}
	sort (d + 1, d + n + 1, cmp);
	for (int i = 1; i <= n; i++) {
		if (d[i].id == 0 || d[i].cnt == 1) {
			continue;
		}
		str = "";
		change1 (d[i].id);
		cout << str << " " << d[i].cnt << endl;
	}
	return 0;
}
